package myky.com.doctorapp.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import myky.com.doctorapp.R
import myky.com.doctorapp.entity.DepatmentAndAreaEntity


/**
 * Title:医生列表科室的适配器
 * Description: TODO
 * @author xiangyao
 * date 2019/1/16
 */
class DoctorLisDepartmentAdapter(mDepartmentList: MutableList<DepatmentAndAreaEntity.DataEntity.DepartmentEntity>)
    : BaseQuickAdapter<DepatmentAndAreaEntity.DataEntity.DepartmentEntity, BaseViewHolder>(R.layout.department_item, mDepartmentList) {

    var selectedDepartMent: String = ""


    fun setDepartMent(province: String) {
        this.selectedDepartMent = province
    }


    override fun convert(holder: BaseViewHolder, item: DepatmentAndAreaEntity.DataEntity.DepartmentEntity) {
        val departmentName = item.departmentname

        holder.setText(R.id.departmentTextView, departmentName)

        if (departmentName.equals(selectedDepartMent)) {
            holder.setBackgroundRes(R.id.department_layout, R.color.white)
        } else {
            holder.setBackgroundRes(R.id.department_layout, R.color.gray_eeeeee)
        }

        holder.addOnClickListener(R.id.department_layout)
    }
}